package com.idbk.chargestation.bean;

import android.text.Html;
import android.text.Spanned;

import com.google.gson.annotations.SerializedName;

import java.util.List;

public class JsonChargeList extends JsonBase {

	@SerializedName("pileInfos")
	public List<ChargePileInfo> pileInfos;

	public static class ChargePileInfo {

		@SerializedName("pileSn")
		public String pileSn;

		@SerializedName("pileType")
		public int pileType;

		@SerializedName("pileStatue")
		public int pileStatue;

		@SerializedName("pileName")
		public String pileName;

		@SerializedName("pileNum")
		public int pileNum;

		@SerializedName("pointName")
		public String pointName;

		@SerializedName("gunInfos")
		public List<ChargeGunInfo> gunInfos;

		public String getPileNum() {
			if (pileNum < 10) {
				return "#0" + pileNum;
			}
			return "#" + pileNum;
		}

		public String getPerformance() {
			switch (pileType) {
			case JsonPointPile.PILE_TYPE_DC:
			case JsonPointPile.PILE_TYPE_DC_DOUBLE_GUN_SYN:
			case JsonPointPile.PILE_TYPE_DC_MULTI_GUN_SYN:
			case JsonPointPile.PILE_TYPE_DC_DOUBLE_GUN_ASYN:
				return "超充";
			case JsonPointPile.PILE_TYPE_AC_SINGLE_PHASE:
			case JsonPointPile.PILE_TYPE_AC_DOUBLE_GUN_SINGLE_PHASE:
			case JsonPointPile.PILE_TYPE_AC_MULTI_GUN_SINGLE_SYN:
			case JsonPointPile.PILE_TYPE_AC_DOUBLE_GUN_THREE_PHASE:
				return "慢充";
			case JsonPointPile.PILE_TYPE_AC_MULTI_GUN_THREE_SYN:
			case JsonPointPile.PILE_TYPE_AC_THREE_PHASE:
				return "快充";
			default:
				return "未知类型" + pileType;
			}
		}
		
		public Spanned getState() {
			String state = "";
			for (int i = 0; i < gunInfos.size(); i++) {
				if (i == 0) {
					state += "<font color= '#37b111'>枪 - " + gunInfos.get(i).gunNum 
							+ " </font> <font color= '#f1a225'>充电中</font>";
					continue;
				}
				state += "<br><font color= '#37b111'>枪 - " + gunInfos.get(i).gunNum 
						+ " </font> <font color= '#f1a225'>充电中</font>";
			}
			Spanned span = Html.fromHtml(state);
			return span;
		}

		public static class ChargeGunInfo {

			@SerializedName("gunNum")
			public int gunNum;

			@SerializedName("gunStatus")
			public int gunStatus;
		}
	}

}
